package com.mi.fastbird.common.spring.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 资源配置
 *
 * @author 王永吉
 * @date 2019/6/27 8:44
 */
@Slf4j
@Configuration
public class ResourceConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //        String path = "/static/**";
        //        if (SystemKit.isLinux()) {
        //            registry.addResourceHandler(path)
        //                    .addResourceLocations("file:" + DictCache.getValueByCode("upload_file_path_linux"));
        //        } else {
        //            registry.addResourceHandler(path)
        //                    .addResourceLocations("file:" + DictCache.getValueByCode("upload_file_path_windows"));
        //        }
        //将templates目录下的CSS、JS文件映射为静态资源，防止Spring把这些资源识别成thymeleaf模版
        //        registry.addResourceHandler("/templates/**.js").addResourceLocations("classpath:/templates/");
        //        registry.addResourceHandler("/templates/**.css").addResourceLocations("classpath:/templates/");
        //其他静态资源
        //        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        //        registry.addResourceHandler("swagger-ui.html")
        //                .addResourceLocations("classpath:/META-INF/resources/");
        //        registry.addResourceHandler("/webjars/**")
        //                .addResourceLocations("classpath:/META-INF/resources/webjars/");
        //        registry.addResourceHandler("/cert/**").addResourceLocations(
        //                "classpath:/cert/");
        log.info(".............. 资源配置完成 ..............");
    }

}
